﻿using System.Configuration;

namespace XrmLibrary.ConfigFile
{

    [ConfigurationCollection(typeof(CrmServiceConfigurationElement))]
    public class CrmServiceConfigurationsCollection : ConfigurationElementCollection
    {
        /// <summary>
        /// When overridden in a derived class, creates a new <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </summary>
        /// <returns>
        /// A new <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new CrmServiceConfigurationElement();
        }

        /// <summary>
        /// Gets the element key for a specified configuration element when overridden in a derived class.
        /// </summary>
        /// <returns>
        /// An <see cref="T:System.Object"/> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </returns>
        /// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement"/> to return the key for. </param>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((CrmServiceConfigurationElement) (element)).CrmOrganizationUrl;
        }

        public CrmServiceConfigurationElement this[int index]
        {
            get { return (CrmServiceConfigurationElement) BaseGet(index); }
        }


        public void Add(CrmServiceConfigurationElement crmServiceConfiguration)
        {
            BaseAdd(crmServiceConfiguration);
        }
    }
}
